home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / LPC / block < prev    next >
Text File  |  2001-04-06  |  1KB  |  47 lines

  1. NAME
  2.         block
  3.  
  4. DESCRIPTION
  5.         A block is a special statment, that begins with '{', contains
  6.         a list of statements, and ends with '}'.
  7.     
  8.         The block may define local variables. If for a variable no
  9.         initialisation is given, the variable is initialised to 0 every
  10.         time the block is entered. Otherwise, the initialisation
  11.         expression is evaluated and its result assigned to the variable
  12.         everytime the block is entered.
  13.         
  14.         Example definitions are:
  15.  
  16.           int i;
  17.           int j = 3;
  18.           int k = 3 * j, l;
  19.  
  20.           Here, i and l are both initialised to 0; j is initialised
  21.           to 3, and k is initialised to 9 (3 * j).
  22.  
  23.         Local variables defined in a block are visible only until the
  24.         end of the block. Definitions in an inner block hide definitions in
  25.         outer blocks.
  26.  
  27. HISTORY
  28.         Up to 3.2.7, local variables were visible (from their point of
  29.         definition) in the whole function. That is, code like
  30.  
  31.             do {
  32.                 int res;
  33.  
  34.                 res = ...
  35.             } while (res == 5);
  36.             write(res);
  37.  
  38.         was perfectly legal. It is no longer, as 'res' ceases to exist
  39.         with the closing '}' of the while().
  40.  
  41.         You can get this old behaviour back with the #pragma no_local_scopes.
  42.         To turn it off again, use #pragma local_scopes.
  43.  
  44.         
  45.         Up to 3.2.8, local variables could not be initialised in their
  46.         definition.
  47.